import React, { useEffect } from "react";
import { Provider } from "react-redux";
import { SET_USER } from "store/constants";
import CreateRoutes from "./components/CreateRoutes";
import routes from "./router";
import store from "./store";

const App: React.FC<any> = () => {
  useEffect(() => {
    const user = localStorage.getItem("token");
    if(user){
      try {
        store.dispatch({type: SET_USER, payload: JSON.parse(user)?.phone})
      }catch{}
    }
  }, [])
  return (<Provider store={store}>
    <CreateRoutes routes={routes} />
  </Provider>);
}

export default App;
